package ja.lingo.engine.beans;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author Manusovich Alexander
 * @version $Id:$
 */
public class CardImpl implements Card {
    private String id;
    private String title;
    private List<Word> words;

    public CardImpl(String title) {
        this.title = title;
        this.id = new SimpleDateFormat("yyMMddHHmmss").format(new Date());
    }

    public String getId() {
        return id;
    }

    public String getTitle() {
        return title;
    }

    public int size() {
        return words != null ? words.size() : 0;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public List<Word> getWords() {
        return words;
    }

    public void setWords(List<Word> words) {
        this.words = words;
    }

    public void addWord(Word w) {
        if (words == null) {
            words = new ArrayList<Word>();
        }
        words.add(w);
    }

    public String toString() {
        return "CardImpl: id: " + id;
    }
}
